import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace TechnicianScheduleApi {
  /** 技师排班信息 */
  export interface TechnicianSchedule {
    id: number; // 主键ID
    technicianId?: number; // 技师ID
    scheduleDate?: string | Dayjs; // 排班日期
    shiftType: string; // 班次类型
    startTime: localtime; // 开始时间
    endTime: localtime; // 结束时间
    workHours: number; // 工作时长(小时)
    status: string; // 状态
    actualStartTime: string | Dayjs; // 实际开始时间
    actualEndTime: string | Dayjs; // 实际结束时间
    actualHours: number; // 实际工作时长
    notes: string; // 备注
    storeId?: number; // 门店ID
    shiftCode: string; // 班次编码
    isOvertime: boolean; // 是否加班
    overtimeHours: number; // 加班时长
    breakTime: number; // 休息时间(分钟)
    statusReason: string; // 状态变更原因
    statusChangedBy: number; // 状态变更人ID
    statusChangedTime: string | Dayjs; // 状态变更时间
  }
}

/** 查询技师排班分页 */
export function getTechnicianSchedulePage(params: PageParam) {
  return requestClient.get<
    PageResult<TechnicianScheduleApi.TechnicianSchedule>
  >('/spa/technician-schedule/page', { params });
}

/** 查询技师排班详情 */
export function getTechnicianSchedule(id: number) {
  return requestClient.get<TechnicianScheduleApi.TechnicianSchedule>(
    `/spa/technician-schedule/get?id=${id}`,
  );
}

/** 新增技师排班 */
export function createTechnicianSchedule(
  data: TechnicianScheduleApi.TechnicianSchedule,
) {
  return requestClient.post('/spa/technician-schedule/create', data);
}

/** 修改技师排班 */
export function updateTechnicianSchedule(
  data: TechnicianScheduleApi.TechnicianSchedule,
) {
  return requestClient.put('/spa/technician-schedule/update', data);
}

/** 删除技师排班 */
export function deleteTechnicianSchedule(id: number) {
  return requestClient.delete(`/spa/technician-schedule/delete?id=${id}`);
}

/** 导出技师排班 */
export function exportTechnicianSchedule(params: any) {
  return requestClient.download('/spa/technician-schedule/export-excel', {
    params,
  });
}
